linux自带了很多kernel module文件, 这些文件一般以 .ko
或 .ko.xz
文件结尾,存放在 /lib/module/$(uname -r)
目录中。
ls -l /lib/modules/$(uname -r)
总用量 5844
drwxr-xr-x 3 root root 4096 6月 1 12:04 build
lrwxrwxrwx 1 root root 25 5月 26 08:26 extramodules -> ../extramodules-4.16-ARCH
drwxr-xr-x 12 root root 4096 6月 1 12:04 kernel
-rw-r--r-- 1 root root 1373746 6月 1 12:05 modules.alias
-rw-r--r-- 1 root root 1351352 6月 1 12:05 modules.alias.bin
-rw-r--r-- 1 root root 4820 5月 26 08:24 modules.builtin
-rw-r--r-- 1 root root 6584 6月 1 12:05 modules.builtin.bin
-rw-r--r-- 1 root root 708369 6月 1 12:05 modules.dep
-rw-r--r-- 1 root root 939730 6月 1 12:05 modules.dep.bin
-rw-r--r-- 1 root root 433 6月 1 12:05 modules.devname
-rw-r--r-- 1 root root 210735 5月 26 08:24 modules.order
-rw-r--r-- 1 root root 598 6月 1 12:05 modules.softdep
-rw-r--r-- 1 root root 610067 6月 1 12:05 modules.symbols
-rw-r--r-- 1 root root 746894 6月 1 12:05 modules.symbols.bin
大部分的module file都按类别分好类存放在其中的 kernel
目录中。
ls -l /lib/modules/$(uname -r)/kernel
总用量 40
drwxr-xr-x 3 root root 4096 6月 1 12:04 arch
drwxr-xr-x 3 root root 4096 6月 1 12:04 crypto
drwxr-xr-x 102 root root 4096 6月 1 12:04 drivers
drwxr-xr-x 48 root root 4096 6月 1 12:04 fs
drwxr-xr-x 6 root root 4096 6月 1 12:04 lib
drwxr-xr-x 2 root root 4096 6月 1 12:04 mm
drwxr-xr-x 52 root root 4096 6月 1 12:04 net
drwxr-xr-x 3 root root 4096 6月 1 12:04 security
drwxr-xr-x 14 root root 4096 6月 1 12:04 sound
drwxr-xr-x 3 root root 4096 6月 1 12:04 virt
linux当然不可能将所有的module都加载进kernel,要查看目前加载了哪些module,可以执行 lsmod
命令:
lsmod |head
加载module特别简单,只需要使用 modprobe module名
就行了。
其中 module名
中无需带 .ko
或 .ko.xz
的后缀名,也无需指定文件路径。
像这样:
sudo modprobe vboxvideo
卸载module也很简单,只需要使用 rmmod module名
就行了。
其中 module名
中也无需带 .ko
或 .ko.xz
的后缀名,也无需指定文件路径。
像这样:
sudo rmmod vboxvideo